import Vue from 'vue'
import App from './App.vue'
import '../static/css/base.css'

import store from './store'

import VueRouter from 'vue-router'
import router from './router'




Vue.config.productionTip = false;
Vue.use(VueRouter)

// 格式化时间
Vue.filter('formatTime',function(el){
    var m =  Math.floor(el /1000 / 60);
    m = m > 9? m:'0' + m;
    var s = Math.floor(el / 1000 % 60);
    s = s > 9? s:'0' + s;
    return m + ':' + s
    
})
// 格式化时间
Vue.filter('formatTime1',function(el){
  
   
   let date = new Date(el);
   let year = date.getFullYear();
   let month = date.getMonth() + 1;   
   let day = date.getDate();
   let h = date.getHours();
    h = h > 9? h: '0' + h;
   let m = date.getMinutes();
    m = m > 9? m:'0' + m
   let date1 = new Date();
  
    if (year == date1.getFullYear()) {
      
       if (month == date1.getMonth() + 1) {

           if (day == date1.getDate()) {
            
             if (date.getHours() == date1.getHours()) {
               if (date.getMinutes + 10 > date1.getMinutes) {
                  return '刚刚'
               } else if (date.getMinutes + 15 > date1.getMinutes) {
                return '15分钟前'
               }else {
                 return h + ':' + m;
               }
             }else {
               return h + ':' + m;
             }
            

           }else if(day == date1.getDate() - 1) {
             return '昨天 ' +  h + ':' + m
           }else {
             return  month + '月' + day + '日 ' + h + ':' + m;
           }

       }else {
        return  month + '月' + day + '日 ' + h + ':' + m; 
       }
   
    }else {
      return year + '年' + month + '月' + day + '日 ';
    }
   
   
})
Vue.filter('t', function(index){
            let date = new Date(index);
           
             return date.getFullYear() + "-" + (date.getMonth() + 1 > 9? date.getMonth() + 1:'0' + date.getMonth() + 1) + "-" + (date.getDate() > 9?date.getDate():'0' + date.getDate()) ;
           
})





new Vue({
   el:'#app',
  render: h => h(App),
  store,
  router,
  beforeCreate(){
    Vue.prototype.$bus = this
  }
})
